package com.zzk.minemodule.ui.userdetail;

import android.app.Application;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.zzk.rxmvvmbase.base.BaseViewModel;
import com.zzk.rxmvvmbase.binding.command.BindingAction;
import com.zzk.rxmvvmbase.binding.command.BindingCommand;
import com.zzk.rxmvvmbase.bus.RxBus;

/**
 *
 * @ProjectName: RXMVVMBaseComponent
 * @Package:
 * @ClassName:
 * @Description:
 * @Author: brilliantzhao
 * @CreateDate: 2021.1.14 9:39
 * @UpdateUser:
 * @UpdateDate: 2021.1.14 9:39
 * @UpdateRemark:
 * @Version: 1.0.0
 */
public class UserDetailViewModel extends BaseViewModel {

    public ObservableField<String> nameObservable = new ObservableField();

    public UserDetailViewModel(@NonNull Application application) {
        super(application);
    }

    public void setName(String name) {
        nameObservable.set(name);
    }

    //回传参数
    public BindingCommand backOnClickCommand = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            if (!TextUtils.isEmpty(nameObservable.get())) {
                //RxBus解耦组件通信
                RxBus.getDefault().post(nameObservable.get());
            }
            finish();
        }
    });
}
